package panda.query.tree;

import java.util.Collection;

import panda.query.scan.ProjectScanner;
import panda.query.scan.Scanner;
import panda.query.struct.Attribute;
import panda.record.Schema;
import panda.transaction.Transaction;

/**
 * 
 * @author Tian Yuan
 *
 */
public class ProjectNode implements QueryTreeNode {
	
	private QueryTreeNode src;
	private Schema sch = new Schema();
	
	public ProjectNode(QueryTreeNode src, Collection<Attribute> attrs, Transaction tx) {
		this.src = src;
		for (Attribute s : attrs)
			sch.addAttribute(s, src.getSchema());
	}
	
	public Scanner open() {
		return new ProjectScanner(src.open(), sch.getAllAttributes());
	}

	public int blockAccessed() {
		return src.blockAccessed();
	}

	public int distinctSize(Attribute attr) {
		return src.distinctSize(attr);
	}

	public Schema getSchema() {
		return sch;
	}

	public int outputSize() {
		return src.outputSize();
	}

}
